(defun pandigit ( l )
  (let ((1to9 '(1 2 3 4 5 6 7 8 9)))
    (if (stringp l) 
	(pandigit (loop for char across l collect (parse-integer (string char))))
	(cond ((/= (length l) (length 1to9)) nil)
	      (t (equal 1to9 (sort l #'<)))))))

(defun generate-string(n)
  (loop 
     for i = 1 then (1+ i) 
     with p = ""
     until (<= 9 (length p))
     do (setq p (concatenate 'string p (write-to-string (* i n))))
     finally (return p)))

(defun probl38()
  (loop for i to 100000  for s = (generate-string i) when (pandigit s) maximize (parse-integer s)))